<!doctype html>
<html>
<head>
    <!--Setting-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="apple-mobile-web-app-capable"  content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no">
    
    
    <!--Simple SEO-->


<meta name="robots" content=all />
<meta name="google" content=all />
<meta name="googlebot" content=all />
<meta name="verify" content=all />
    <!--Title-->

<title>pyenv | MIAbon&#39;s blog</title>

<link rel="alternate" href="/atom.xml" title="MIAbon&#39;s blog" type="application/atom+xml">


<link rel="icon" href="/favicon.ico">

    
<link rel="stylesheet" href="/css/base.css">
<link rel="stylesheet" href="/css/pages/post.css">
<link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/thirdParty/highlight/github.css">
<link rel="stylesheet" href="/.css">

    <!--script-->


<script src="http://cdn1.lncld.net/static/js/3.2.1/av-min.js"></script>
<script>
  var appId = "i7AHmC7NPbPtgS3YxT67dRIc-9Nh9j0Va";
  var appKey = "g6TKbY8O4TsCDMcemoC3STvQ";
  var region = "";
  AV.init({
    appId: appId,
    appKey: appKey,
    region: region
  });
</script>


<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<!--<script src="https://imsun.github.io/gitment/dist/gitment.browser.js"></script>-->


    
    
</head>

<body id="normal">
<!--[if lte IE 8]>
<style>
    html{ font-size: 1em }
</style>
<![endif]-->
<!--[if lte IE 9]>
<style>
    header{ top: 71px; position: absolute!important;}
    #container{padding-top: 151px!important;}
</style>
<div style="position:fixed;z-index:9999;left:0;top:0;width:100%;height:70px;background-color:#e0e0e0;color:#396CA5;border-bottom:1px solid #cecece;text-align:center;line-height:70px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis">你使用的浏览器版本过低，为了你更好的阅读体验，请更新浏览器的版本或者使用其他现代浏览器，比如Chrome、Firefox、Safari等。</div>
<![endif]-->

<div id="wrap">
    <header  style="position: absolute;" >
    <div id="site-meta">
        <a href="/" id="logo">
            <h1 class="title">MIAbon&#39;s blog</h1>
        </a>
        
    </div>
    <ul id="nav">
        
            <li><a href="/"><i class="fa fa-home"></i>首页</a></li>
        
            <li><a href="/atom.xml"><i class="fa fa-rss"></i>RSS</a></li>
        
        <li id="search"><a href="javascript:void(0)"><i class="fa fa-search"></i>搜索</a></li>
    </ul>
</header>

    <div id="container">
        
<ul id="sidebar">
    
    
    
    
<li class="widget widget-normal category">
    <h3 class="fa fa-th widget-title">分类</h3>
    <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/ELK/"><i class="fa" aria-hidden="true">ELK</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Lvs/"><i class="fa" aria-hidden="true">Lvs</i></a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/admin/"><i class="fa" aria-hidden="true">admin</i></a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/ansible/"><i class="fa" aria-hidden="true">ansible</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/aws/"><i class="fa" aria-hidden="true">aws</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/"><i class="fa" aria-hidden="true">docker</i></a><span class="category-list-count">7</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/drone/"><i class="fa" aria-hidden="true">drone</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/kernel/"><i class="fa" aria-hidden="true">kernel</i></a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/kubernetes/"><i class="fa" aria-hidden="true">kubernetes</i></a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/kvm/"><i class="fa" aria-hidden="true">kvm</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mongodb/"><i class="fa" aria-hidden="true">mongodb</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link current" href="/categories/python/"><i class="fa" aria-hidden="true">python</i></a><span class="category-list-count">9</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/share/"><i class="fa" aria-hidden="true">share</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/web/"><i class="fa" aria-hidden="true">web</i></a><span class="category-list-count">12</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/zabbix/"><i class="fa" aria-hidden="true">zabbix</i></a><span class="category-list-count">3</span></li></ul>
</li>


    
    
<li class="widget widget-normal archive">
  <h3 class="fa fa-archive widget-title">归档</h3>
    <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/"><i class="fa" aria-hidden="true">二月 2018</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/01/"><i class="fa" aria-hidden="true">一月 2018</i></a><span class="archive-list-count">8</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/12/"><i class="fa" aria-hidden="true">十二月 2017</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/11/"><i class="fa" aria-hidden="true">十一月 2017</i></a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/10/"><i class="fa" aria-hidden="true">十月 2017</i></a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/09/"><i class="fa" aria-hidden="true">九月 2017</i></a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/08/"><i class="fa" aria-hidden="true">八月 2017</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/"><i class="fa" aria-hidden="true">五月 2017</i></a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/"><i class="fa" aria-hidden="true">四月 2017</i></a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/"><i class="fa" aria-hidden="true">三月 2017</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/01/"><i class="fa" aria-hidden="true">一月 2017</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/12/"><i class="fa" aria-hidden="true">十二月 2016</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/11/"><i class="fa" aria-hidden="true">十一月 2016</i></a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/"><i class="fa" aria-hidden="true">十月 2016</i></a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/"><i class="fa" aria-hidden="true">八月 2016</i></a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/05/"><i class="fa" aria-hidden="true">五月 2016</i></a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/"><i class="fa" aria-hidden="true">四月 2016</i></a><span class="archive-list-count">8</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/05/"><i class="fa" aria-hidden="true">五月 2015</i></a><span class="archive-list-count">1</span></li></ul>
</li>


    
    
<li class="widget widget-normal tags">
  <h3 class="fa fa-tags widget-title">标签云</h3>
  <div class="tagcloud-content">
    
      <a href="/tags/drone/" style="font-size: 0.14rem; color: #69c">drone</a> <a href="/tags/linux/" style="font-size: 0.2rem; color: #0a407c">linux</a> <a href="/tags/kernel/" style="font-size: 0.16rem; color: #4f83b8">kernel</a> <a href="/tags/ELK/" style="font-size: 0.14rem; color: #69c">ELK</a> <a href="/tags/ansible/" style="font-size: 0.14rem; color: #69c">ansible</a> <a href="/tags/swarm/" style="font-size: 0.14rem; color: #69c">swarm</a> <a href="/tags/docker/" style="font-size: 0.18rem; color: #215690">docker</a> <a href="/tags/firewalld/" style="font-size: 0.14rem; color: #69c">firewalld</a> <a href="/tags/zabbix/" style="font-size: 0.16rem; color: #4f83b8">zabbix</a> <a href="/tags/aws/" style="font-size: 0.14rem; color: #69c">aws</a> <a href="/tags/web/" style="font-size: 0.16rem; color: #4f83b8">web</a> <a href="/tags/python/" style="font-size: 0.18rem; color: #215690">python</a> <a href="/tags/spider/" style="font-size: 0.17rem; color: #386da4">spider</a>
  </div>
</li>


    
    
<li class="widget widget-normal friends-link">
    <h3 class="fa fa-globe widget-title">友链</h3><br/>

    
        <a href="http://zhengwei666.wang" class="fa" target="_blank">zhengwei</a>

    
        <a href="https://you-deng.github.io" class="fa" target="_blank">dengyou</a>

    
        <a href="http://www.systemd.cn" class="fa" target="_blank">langyaoliang</a>

    
        <a href="http://www.chen-hao.com.cn/" class="fa" target="_blank">chenhao</a>

    
        <a href="http://www.yulongjun.com" class="fa" target="_blank">yulongjun</a>

    

</li>

    
</ul>


        <div id="main">
    <article id="post">
        <div id="post-header">

            <h1 id="pyenv">
                
                pyenv
                
            </h1>
            <div class="article-meta">
    
    
    <span class="categories-meta fa-wrap">
            <i class="fa fa-folder-open-o"></i>
        <span>python</span>
    </span>
    
    
    <span class="fa-wrap">
         <i class="fa fa-tags"></i>
        <span class="tags-meta">
            
            null
            
        </span>
    </span>
    
    
    <span class="fa-wrap">
        <i class="fa fa-clock-o"></i>
        <span class="date-meta ">2017/05/10</span>
    </span>
    
    
    <span class="fa-wrap">
            <i class="fa fa-thermometer-three-quarters"></i>
        <span class="hits hits-meta " data-leadcloud-title="pyenv"
              data-leadcloud-url="/2017/05/10/pyenv环境及python3.5.2安装/"><i class="fa fa-spinner fa-spin"></i></span>
    </span>
    
    
</div>

            
            
        </div>
        
        <div id="post-body">
            <h2 id="一、安装pyenv"><a href="#一、安装pyenv" class="headerlink" title="一、安装pyenv"></a>一、安装pyenv</h2><h4 id="1-安装git"><a href="#1-安装git" class="headerlink" title="1.安装git"></a>1.安装git</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@python:~]# yum install -y git</div><div class="line">sudo apt-get install -y build-essential zlib1g-dev libssl-dev</div><div class="line">sudo apt-get install libsqlite3-dev libbz2-dev libreadline-dev</div></pre></td></tr></table></figure>
<h4 id="2-安装pyenv"><a href="#2-安装pyenv" class="headerlink" title="2.安装pyenv"></a>2.安装pyenv</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">[root@python ~]# curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash</div><div class="line">WARNING: seems you still have not added &apos;pyenv&apos; to the load path.</div><div class="line"># Load pyenv automatically by adding</div><div class="line"># the following to ~/.bash_profile:</div><div class="line">export PATH=&quot;/root/.pyenv/bin:$PATH&quot;</div><div class="line">eval &quot;$(pyenv init -)&quot;</div><div class="line">eval &quot;$(pyenv virtualenv-init -)&quot;</div></pre></td></tr></table></figure>
<h4 id="3-环境变量配置。（可在全局配置，也可以在局部配置）"><a href="#3-环境变量配置。（可在全局配置，也可以在局部配置）" class="headerlink" title="3.环境变量配置。（可在全局配置，也可以在局部配置）"></a>3.环境变量配置。（可在全局配置，也可以在局部配置）</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[root@python ~]# vim /etc/profile.d/pyenv.sh</div><div class="line">export PATH=&quot;/root/.pyenv/bin:$PATH&quot;</div><div class="line">eval &quot;$(pyenv init -)&quot;</div><div class="line">eval &quot;$(pyenv virtualenv-init -)&quot;</div><div class="line">[root@python ~] # . /etc/profile.d/pyenv.sh</div></pre></td></tr></table></figure>
<h2 id="二、安装python3-5-2"><a href="#二、安装python3-5-2" class="headerlink" title="二、安装python3.5.2"></a>二、安装python3.5.2</h2><h4 id="方法一：针对于网络不好的情况七牛上下载网络包（magedu提供）"><a href="#方法一：针对于网络不好的情况七牛上下载网络包（magedu提供）" class="headerlink" title="方法一：针对于网络不好的情况七牛上下载网络包（magedu提供）"></a>方法一：针对于网络不好的情况七牛上下载网络包（magedu提供）</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div></pre></td><td class="code"><pre><div class="line">[root@python ~]# mkdir ~/.pyenv/cache</div><div class="line">[root@python ~]# wget http://7d9qvq.com1.z0.glb.clouddn.com/Python-3.5.2.tgz</div><div class="line">[root@python ~]# ls</div><div class="line">anaconda-ks.cfg  Python-3.5.2.tgz</div><div class="line">[root@python ~]# mv Python-3.5.2.tgz ~/.pyenv/cache/Python-3.5.2.tar.gz</div><div class="line">[root@python ~]# yum install -y gcc make patch</div><div class="line">[root@python ~]# yum -y install gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel</div><div class="line">[root@python ~]# pyenv  install  3.5.2</div><div class="line">Downloading Python-3.5.2.tar.xz...</div><div class="line"> https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz</div><div class="line">Installing Python-3.5.2...</div><div class="line">patching file Lib/venv/scripts/posix/activate.fish</div><div class="line">Installed Python-3.5.2 to /root/.pyenv/versions/3.5.2</div><div class="line">[root@python ~]# pyenv versions</div><div class="line">* system (set by /root/.pyenv/version)</div><div class="line">  3.5.2</div></pre></td></tr></table></figure>
<h4 id="方法二、网络好的情况下，通过官网安装"><a href="#方法二、网络好的情况下，通过官网安装" class="headerlink" title="方法二、网络好的情况下，通过官网安装"></a>方法二、网络好的情况下，通过官网安装</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">1.安装编译工具 `yum -y install gcc make patch`</div><div class="line">2.安装依赖 `yum -y install gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel`</div><div class="line">3. mkdir ~/.pyenv/cache/</div><div class="line">4.wget http://7d9qvq.com1.z0.glb.clouddn.com/Python-3.5.2.tgz -O  ~/.pyenv/cache/Python-3.5.2.tar.gz</div><div class="line">5.安装Python 3.5.2 `pyenv install 3.5.2`</div></pre></td></tr></table></figure>
<h2 id="三、pyenv用法"><a href="#三、pyenv用法" class="headerlink" title="三、pyenv用法"></a>三、pyenv用法</h2><h4 id="versions命令"><a href="#versions命令" class="headerlink" title="versions命令"></a>versions命令</h4><p> 查看已经安装的python 版本 及可安装的python版本及更新<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@python:~] # pyenv versions</div><div class="line">[root@python:~] # pyenv  install --list</div><div class="line">[root@python:~] # pyenv update</div></pre></td></tr></table></figure></p>
<h4 id="local命令"><a href="#local命令" class="headerlink" title="local命令"></a>local命令</h4><p>local命令切换当前目录及其子目录的python版本，可以通过<code>rm -rf .python-version</code> 恢复默认的Python版本<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">[root@python ~]# pyenv local 3.5.2</div><div class="line">[root@python ~]# pyenv version</div><div class="line">3.5.2 (set by /root/.python-version)</div><div class="line">[root@python ~]# rm -rf .python-version </div><div class="line">[root@python ~]# pyenv version</div><div class="line">system (set by /root/.pyenv/version)</div><div class="line">[root@python ~]# python -V</div><div class="line">Python 2.7.5</div><div class="line">[root@python ~]#</div></pre></td></tr></table></figure></p>
<h4 id="global命令"><a href="#global命令" class="headerlink" title="global命令"></a>global命令</h4><p>global命令切换全局默认的python版本</p>
<p><strong>注意</strong>永远不要使用此命令，在生产环境中是非常危险的</p>
<h4 id="virtualenv命令"><a href="#virtualenv命令" class="headerlink" title="virtualenv命令"></a>virtualenv命令</h4><p><code>virtualenv</code>是一个基于site的插件，python的基于<code>site</code>开发的，而不像java基于project开发。site是指一个机器使用同一个环境，这是与java的一次编译到处运行是不同的。早期人们认为一个机器就是用一个python环境就可以了，但是这无法满足现今的要求，于是有人提出的虚拟环境，此类似于java基于project开发一样，使得<strong>同一台机器上也可以提供多个pythonn环境</strong>了。我们可以通过<code>pyenv commands</code>来查看其用并创建<code>virtualenv</code><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@python:~] `pyenv virtualenv 3.5.2 rex`</div><div class="line">[root@python:~] `pyenv versions`</div><div class="line">  system</div><div class="line">* 3.5.2 (set by /root/.python-version)</div><div class="line">  3.5.2/envs/rex</div><div class="line">  rex</div></pre></td></tr></table></figure></p>
<p><strong>注意：<code>3.5.2/envs/rex</code>和<code>rex</code>是同一个环境，只是rex是为了兼容旧版本而存在的,并且rex是一个链接文件</strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">[root@python:~] `pyenv versions`</div><div class="line">system</div><div class="line">* 3.5.2 (set by /root/.python-version)</div><div class="line">3.5.2/envs/rex</div><div class="line">rex</div><div class="line">[root@python:~] `pyenv local 3.5.2/envs/rex`</div><div class="line">(3.5.2/envs/rex) [root@python:~] python -V</div><div class="line">Python 3.5.2</div><div class="line">(3.5.2/envs/rex) [root@python:~] pyenv versions</div><div class="line">system</div><div class="line">3.5.2</div><div class="line">* 3.5.2/envs/rex (set by /root/.python-version)</div><div class="line">rex</div></pre></td></tr></table></figure></p>
<h3 id="uninstall命令"><a href="#uninstall命令" class="headerlink" title="uninstall命令"></a>uninstall命令</h3><p>卸载rex pyenv (3.5.2/envs/rex)<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@python:~] `pyenv local 3.5.2`</div><div class="line">[root@python:~] pyenv uninstall rex</div><div class="line">pyenv-virtualenv: remove /root/.pyenv/versions/3.5.2/envs/rex? y</div><div class="line">[root@python:~] `pyenv versions`</div><div class="line">  system</div><div class="line">* 3.5.2 (set by /root/.python-version)</div></pre></td></tr></table></figure></p>
<h2 id="四、安装ipython"><a href="#四、安装ipython" class="headerlink" title="四、安装ipython"></a>四、安装ipython</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">[root@python ~]# pip install -y ipython</div><div class="line">报错：</div><div class="line">You are using pip version 8.1.1, however version 9.0.1 is available.</div><div class="line">You should consider upgrading via the &apos;pip install --upgrade pip&apos; command.</div><div class="line">解决办法：</div><div class="line">[root@python ~]# pip install  --upgrade pip</div><div class="line">[root@python ~]# pip install  ipython</div><div class="line">使用：</div><div class="line">[root@python ~]# ipython</div><div class="line">Python 3.5.2 (default, Nov 30 2016, 22:30:32) </div><div class="line">In [1]: print (&quot;hello world&quot;)</div><div class="line">hello world</div><div class="line">In [2]: exit()</div></pre></td></tr></table></figure>
<h2 id="五、安装jupyter"><a href="#五、安装jupyter" class="headerlink" title="五、安装jupyter"></a>五、安装jupyter</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@python ~]# pip install jupyter</div><div class="line">[root@python ~]# jupyter notebook --ip=0.0.0.0 --no-browser</div><div class="line">[I 22:52:04.794 NotebookApp] Writing notebook server cookie secret to /run/user/0/jupyter/notebook_cookie_secret</div><div class="line">[I 22:52:04.841 NotebookApp] Serving notebooks from local directory: /root</div><div class="line">[I 22:52:04.841 NotebookApp] 0 active kernels </div><div class="line">[I 22:52:04.841 NotebookApp] The Jupyter Notebook is running at: http://0.0.0.0:8888/</div><div class="line">[I 22:52:04.841 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).</div></pre></td></tr></table></figure>
<ul>
<li>浏览器：<a href="http://Ipaddr:8888" target="_blank" rel="external">http://Ipaddr:8888</a><ul>
<li><a href="http://192.168.99.7:8888/tree" target="_blank" rel="external">http://192.168.99.7:8888/tree</a></li>
</ul>
</li>
</ul>
<h2 id="virtualenv"><a href="#virtualenv" class="headerlink" title="virtualenv"></a>virtualenv</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">pyenv virtualenv 3.3.0 env    <span class="comment">#创建一个 Python 版本为 3.3.0 的环境, 环境叫做 env</span></div><div class="line">pyenv activate env_name       <span class="comment">#激活 env 这个环境, 此时 Python 版本自动变为 3.3.0, 且是独立环境</span></div><div class="line">pyenv deactivate              <span class="comment">#离开已经激活的环境</span></div></pre></td></tr></table></figure>
<p>创建虚拟环境–pyenv virtualenv 版本号 虚拟环境名。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">$ pyenv virtualenv 3.5.2 venv-3.5.2</div><div class="line">创建项目，让项目使用干净的Python3.5.2的虚拟环境：</div><div class="line">$ mkdir myproject</div><div class="line">$ <span class="built_in">cd</span> myproject</div><div class="line">$ pyenv <span class="built_in">local</span> venv-3.5.2</div></pre></td></tr></table></figure></p>
<p>此后，我们就会发现：只要我们进入myproject目录，就会自动激活virtualenv，退出myproject目录，就会关闭virtualenv。</p>
<p>如果要关闭自动激活，可以运行命令pyenv deactivate，要重新启用的话，运行pyenv activate 虚拟环境名。</p>

        </div>
        <div id="post-footer">
            <div class="avatar" >
                <img src="/img/author.jpg" alt="avatar"/>
                <!-- 
                <a href="javascript:void(0)" class="high-song">high起来 &#128541;</a>
                 -->
                
                <a href="http://backup-miabon.oss-cn-hongkong.aliyuncs.com/img/alipay.jpg" target="_blank" class="donate fa">打赏小弟 &#128536;</a>
                
            </div>
            <ul class="author-profile-section">
                <li>
                  
                  作者:
                  
                    
                    <a href="/about.html">MIAbon</a>
                </li>
                
                <li>发表日期: <span>2017-05-10  08:00:00</span></li>
                
                <li>最后编辑日期: <span>2017-11-23  08:23:00</span></li>
                
                <li class="post-category">
                    文章分类:
                    
                    <a href="/categories/python/">python</a>
                    
                </li>
                <li class="post-tags">
                    文章标签:
                    
                </li>
                
                <li> 版权声明: <a href="https://creativecommons.org/licenses/by-nc-nd/3.0/" target="_blank">
知识共享署名-非商业性使用-禁止演绎 3.0 未本地化版本许可协议（CC BY-NC-ND 3.0）
</a></li>
                
            </ul>
            <div id="donate-wrap">
                
                
                
                <img src="http://www.geasslinks.com/img/alipay.jpg" alt="支付宝付款" class="donate-img">
                
                
            </div>
        </div>
    </article>
    <div class="article-nav">
        
        <a href="/2017/05/10/快速安装Kubernetes/" class="pre-post fa fa-caret-left">单机Kubernetes</a>
        
        
        <a href="/2017/04/01/zabbix3.0安装/" class="next-post fa">zabbix3.0安装</a>
        
    </div>
    
    <div id="comments">
        

<script>
  gitment.render(document.getElementById("comments"));
</script>



    </div>
    
</div>


    </div>
    <footer id="footer">
    
    <div class="social">
        
        <a href="https://www.example1.com" class="fa fa-free-code-camp" target="_blank" title="freecodecamp"></a>
        
        <a href="https://github.com/werewolf2101" class="fa fa-github" target="_blank" title="Follow me~"></a>
        
        <a href="mailto:werewolf2101@gmail.com" class="fa fa-email" target="_blank" title="Email"></a>
        
    </div>
    
    <div>
        
        <a href="/" class="copyright-links">MIAbon</a>&copy;2015 - 2018.All Rights
        Reserved.
    </div>
    <p>Powered by <a href="https://hexo.io" class="copyright-links" target="_blank">Hexo</a> | Theme by <a
                href="https://github.com/GeekaholicLin" class="copyright-links" target="_blank">GeekaholicLin</a>
    </p>
    
    
    <p>
        <span id="busuanzi_container_site_uv" class="fa fa-bar-chart">
        欢迎第<span id="busuanzi_value_site_uv"><i class="fa fa-spinner fa-spin"></i></span>位小伙伴~
        </span>
    </p>
    
</footer>

</div>
    <ul id="tools">
    <li class="totop-btn fa fa-angle-up"></li>
    <li class="exchange-btn fa fa-exchange"></li>
  
    <li class="toc-btn fa fa-list-ul"></li>
    
    

    
</ul>
<p id="process"></p>
<div id="search-overlay">
    <div class="search-area-wrap">
        <div id="search-area">
            <div class="input-wrap focus">
                <i class="fa fa-search" aria-hidden="true"></i>
                <input id="search-input" autofocus autocomplete="off" type="text"
                       placeholder="search this website..."/>
            </div>
            <ul id="search-result">
                <li class="load-first"><i class="fa fa-spinner fa-pulse"></i></li>
            </ul>
        </div>
    </div>
</div>

    <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#一、安装pyenv"><span class="toc-number">1.</span> <span class="toc-text">一、安装pyenv</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-安装git"><span class="toc-number">1.0.1.</span> <span class="toc-text">1.安装git</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-安装pyenv"><span class="toc-number">1.0.2.</span> <span class="toc-text">2.安装pyenv</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-环境变量配置。（可在全局配置，也可以在局部配置）"><span class="toc-number">1.0.3.</span> <span class="toc-text">3.环境变量配置。（可在全局配置，也可以在局部配置）</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#二、安装python3-5-2"><span class="toc-number">2.</span> <span class="toc-text">二、安装python3.5.2</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#方法一：针对于网络不好的情况七牛上下载网络包（magedu提供）"><span class="toc-number">2.0.1.</span> <span class="toc-text">方法一：针对于网络不好的情况七牛上下载网络包（magedu提供）</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#方法二、网络好的情况下，通过官网安装"><span class="toc-number">2.0.2.</span> <span class="toc-text">方法二、网络好的情况下，通过官网安装</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#三、pyenv用法"><span class="toc-number">3.</span> <span class="toc-text">三、pyenv用法</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#versions命令"><span class="toc-number">3.0.1.</span> <span class="toc-text">versions命令</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#local命令"><span class="toc-number">3.0.2.</span> <span class="toc-text">local命令</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#global命令"><span class="toc-number">3.0.3.</span> <span class="toc-text">global命令</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#virtualenv命令"><span class="toc-number">3.0.4.</span> <span class="toc-text">virtualenv命令</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#uninstall命令"><span class="toc-number">3.1.</span> <span class="toc-text">uninstall命令</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#四、安装ipython"><span class="toc-number">4.</span> <span class="toc-text">四、安装ipython</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#五、安装jupyter"><span class="toc-number">5.</span> <span class="toc-text">五、安装jupyter</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#virtualenv"><span class="toc-number">6.</span> <span class="toc-text">virtualenv</span></a></li></ol>


    <script src="/js/highsong.js"></script>



<script src="/js/search.js"></script>
<script type="text/javascript">
    //theme config datas
    var copyrightObj = {};
    copyrightObj.enable = 'true';
    copyrightObj.triggerCopyLength = '200';
    copyrightObj.appendText = '商业转载请联系作者获得授权,非商业转载请注明出处 © gasslinks.com';
    var leancloudObj = {};
    leancloudObj.enable = 'true';
    leancloudObj.className = 'blog';
    leancloudObj.limits = '5';
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?dfebe5842f5d4196471b84802392a4b2";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<script type="text/javascript">
    var search = {};
    var search_path = "search.xml";
    if (!search_path) {
        search_path = "search.xml";
    }
    search.path = "/" + search_path;
    search.func =  _ajax.init();
</script>
<script src="/js/app.js"></script>


</body>
</html>